package com.itheima.mysort;

public class A01_BubbleDemo1 {
    public static void main(String[] args) {
        //冒泡排序
        int[] arr = {4, 2, 1, 3, 7, 10, 5, 8, 9, 6};

        //交换容器
        int temp = 0;

        //循环
        for (int i = 0; i < arr.length-1; i++) {
            for (int j = 0; j < arr.length-1-i; j++) {
                //比较
                if(arr[j] > arr[j+1]) {
                    //交换
                    temp = arr[j];
                    arr[j] = arr[j+1];
                    arr[j+1] = temp;
                }
            }
        }
        //排序完成
        //输出查验
        for (int i = 0; i < arr.length; i++) {
            System.out.print(arr[i]+" ");
        }
    }
}
